using System;
using System.Data;
using System.Windows.Forms;
using ctsu.Data;

namespace ctsu.Admin.Forms.CoreLab
{
	public partial class SstQueryPatient : Form
	{
		public SstQueryPatient()
		{
			InitializeComponent();
		}

		private void rdo_CheckedChanged(object sender, EventArgs e)
		{
			txtCrit.Text = "";
			if (rdo1.Checked)
			{
				txtCrit.Top = 32;
				btnSearch.Top = 32;
			}
			if (rdo2.Checked)
			{
				txtCrit.Top = 55;
				btnSearch.Top = 55;
			}
			if (rdo3.Checked)
			{
				txtCrit.Top = 78;
				btnSearch.Top = 78;
			}
		}

		private void btnSearch_Click(object sender, EventArgs e)
		{
			string sql = "SELECT * FROM SST WHERE ";
			if (rdo1.Checked)
				sql += "PatientName ";
			if (rdo2.Checked)
				sql += "MRN ";
			if (rdo3.Checked)
				sql += "OtherID ";

			sql += "LIKE'" + txtCrit.Text + "%'";

			DataSet ds = DataAccess.GetDataSet(sql);
			DataTable dt = ds.Tables[0];

			BindingSource bs = new BindingSource();
			bs.DataSource = dt;
			dgv.DataSource = bs;
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}